/*
 * Copyright(c)2018,2024,guowenmeng24@163.comAllrightsreserved.
 */
package com.bkhech.plumelog;

import com.yomahub.tlog.core.annotation.TLogAspect;
import com.yomahub.tlog.resttemplate.TLogRestTemplateInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;

/**
 * TestController
 *
 * @author guowm
 * @date 2024/07/08
 */
@RestController
@Slf4j
public class TestController {

    @RequestMapping("/test")
    public String test() {
        log.info("=========={}==========", System.currentTimeMillis());

        final RestTemplate restTemplate = new RestTemplate();
        restTemplate.setInterceptors(Collections.singletonList(new TLogRestTemplateInterceptor()));

        final ResponseEntity<String> response = restTemplate.getForEntity("http://localhost:8888/test2?orderId="+ System.currentTimeMillis() +"&name=业务标签测试", String.class);
        log.info("===response, code: {}, content: {}==", response.getStatusCode(), response.getBody());

        return "test";
    }

    @TLogAspect({"orderId"})
    @RequestMapping("/test2")
    public String test(String orderId,String name) {
        log.info("===request, orderId: {}，name: {}==", orderId, name);
        return "test";
    }

}